﻿using System;
using System.Collections.Generic;
using System.Text;
using Dare.Utilities.IO;

namespace Dare.Utilities.Net.Ftp
{
    public class FtpItem : IComparable, IComparable<FtpItem>
    {
        public FtpItem()
        {
            name = String.Empty;
            date = DateTime.MinValue;
            rawAttributes = String.Empty;
            owner = String.Empty;
            group = String.Empty;
            attributes = new UnixFileAttribute();
        }

        private string name;

        public string Name
        {
            get { return name; }
            set { name = value; }
        }
        private DateTime date;

        public DateTime Date
        {
            get { return date; }
            set { date = value; }
        }

        private UnixFileAttribute attributes;

        public UnixFileAttribute Attributes
        {
            get { return attributes; }
            set { attributes = value; }
        }

        private string rawAttributes;

        public string RawAttributes
        {
            get { return rawAttributes; }
            set { rawAttributes = value; }
        }
        private string owner;

        public string Owner
        {
            get { return owner; }
            set { owner = value; }
        }
        private string group;

        public string Group
        {
            get { return group; }
            set { group = value; }
        }

        #region IComparable<FtpItem> 成员

        public int CompareTo(FtpItem other)
        {
            if (other == null) return 1;

            if (attributes.FileType == other.attributes.FileType)
            {
                return name.CompareTo(other.name);
            }
            else
            {
                return attributes.FileType.CompareTo(other.attributes.FileType);
            }
        }

        #endregion

        #region IComparable 成员

        public int CompareTo(object obj)
        {
            return this.CompareTo(obj as FtpItem);
        }

        #endregion
    }
}
